package Testdmo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Testdmo1.Date: 2024-02-24
 * Time：22:58
 */
public class J2_24 {
    //   冒泡排序
    public static void bubbleSort(int []arr){
        for (int i = 0; i < arr.length-1 ; i++) {
            for (int j = 0; j < arr.length-1-i ; j++) {
                if (arr[j+1]<arr[j]){
                    int tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                }
            }
        }

    }

    public static void main(String[] args) {
        int []arry = {6,2,9,10,7,1,8,4,3,};
        bubbleSort(arry);
        for (int x:arry
        ) {
            System.out.println(x);
        }

    }
}
